# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rmagick
_gemname=rmagick
pkgver=5.3.0
_pkgver=${pkgver//./-}
pkgrel=1
pkgdesc="Ruby bindings for ImageMagick"
url="https://github.com/rmagick/rmagick"
arch="all"
license="MIT"
depends="ghostscript-fonts"
makedepends="
	imagemagick-dev
	ruby
	ruby-dev
	ruby-pkg-config
	"
checkdepends="
	imagemagick
	imagemagick-pdf
	ruby-rake
	ruby-rspec
	"
source="https://github.com/rmagick/rmagick/archive/RMagick_$_pkgver.tar.gz
	gemspec.patch
	spec-drop-pry.patch
	dont-test-webp.patch
	skip-broken-test.patch
	fix-tempfile.patch
	"
builddir="$srcdir/rmagick-RMagick_$_pkgver"

build() {
	gem build $_gemname.gemspec
	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	GEM_PATH='dist:.gem' rspec
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete

	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -r ext/ lib/*.so
}

sha512sums="
dcc9e0d7cd77ebd3859871f26449c37839f9102e7aa4f0746698cbd6fe93579c3adbe6cfefeba6cdcb53e573f5113b872d03fcd568bb80edda5c8ca9c1ab1665  RMagick_5-3-0.tar.gz
f653a3588cc529b0f98bc951f18c67f4e013ffacdb2a8ad9f5495e484d083bf1a37b246ae1b2eea570aa3916d9607844f128a4d3dfbbd49ad390e8222f63b6e4  gemspec.patch
6550535ebaf3924b9f707da395eeaec630e5db50e1964ab9f84d2f941d97c7c49eb7dff05439efa355abb97e72556385b26b8af1d86e05b7c12fd8f2f781834a  spec-drop-pry.patch
5eeea508d44f2c9679fe4fe3d5b9a51470f8022537f5822f85c95dbd4d78149c2cada763f0bdf3e86523770b0b758117a6d216b240c92f54253905c19d38d064  dont-test-webp.patch
1e3a2e1deeb473d0da6824a9fbeb66df027adf248583c41991ef457146b59cb3aa2e5ad20deb307a5632c5c25ddcd5e96d4afa857fa09aba36770b940931683c  skip-broken-test.patch
c661ca0c22d93795e5c2c89bbac7cb577b4bc32ec2cb4906cb49a6fa2d109a429d963fea7089d04c4750531f2c0c5a77eee1998db0741520dc81f0c5cfb04d8b  fix-tempfile.patch
"
